package com.ahu.rs.admin.service.impl;

import cn.hutool.core.lang.UUID;
import com.ahu.rs.admin.dao.entity.UserDO;
import com.ahu.rs.admin.dao.mapper.UserMapper;
import com.ahu.rs.admin.dto.req.UserLoginReqDTO;
import com.ahu.rs.admin.dto.resp.UserLoginRespDTO;
import com.ahu.rs.admin.service.UserService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;


@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements UserService {

    @Override
    public UserLoginRespDTO login(UserLoginReqDTO requestParam) {
        LambdaQueryWrapper<UserDO> lambdaQueryWrapper = Wrappers.lambdaQuery(UserDO.class)
                .eq(UserDO::getUsername, requestParam.getUsername())
                .eq(UserDO::getPassword, requestParam.getPassword())
                .eq(UserDO::getDelFlag, 0);

        UserDO userDO = baseMapper.selectOne(lambdaQueryWrapper);
        UserLoginRespDTO loginRespDTO = new UserLoginRespDTO();
        loginRespDTO.setToken(UUID.randomUUID().toString());
        return loginRespDTO;
    }
}
